import request from "@/utils/request.js"


// 商家登录
export function adminLogin(data){
    return request({
        url:'loginAdmin',
        method:"POST",
        data,
        headers: {
            // isToken:false
        }
    })
}


// 获取轮播图
export function getBanner(params){
    return request({
        url:"carousel",
        method:"GET",
        params,
    })
}

// 获取商品信息
export function Shoptext(params){
    return request({
        url:"classify/classifyGoods",
        method:"GET",
        params,
        headers:{'isToken':false , "UserToken":true}
    })
}

// 获取商品图片
export function Shopimg(params){
    return request({
        url:"goods",
        method:"GET",
        params,
    })
}

// 用户注册
export function user_register(data){
    return request({
        url:"register",
        method:"POST",
        data
    })
}

//用户登录
export function userLogin(data){
    return request({
        url:'/login',
        method:'POST',
        data,
    })
}

// 获取单个商品信息
export function singleshop(params){
    return request({
        url:`goods/${params}`,
        method:'GET',
        headers:{'isToken':false}
    })
}
export function Searchgoods(params) {
    return request({
      url: `goodsSearch/`,
      method: "GET",
      params,
      // headers:{'isToken':false , "UserToken":true}
    });
  }
// 添加购物车
export function AddCar(data){
    return request({
        url:"shoppingCart",
        method:"POST",
        data,
        headers:{'isToken':false ,"UserToken":true}
    })
}

// 获取购物车的信息
export function shopCar(params){
    return request({
        url:`/shoppingCart`,
        method:"GET",
        params,
        headers:{'isToken':false , "UserToken":true}
    })
}

// 删除购物车单条信息
export function shopCarDel(data){
    return request({
        url:`/shoppingCart/${data}`,
        method:"DELETE",
        headers: { 'isToken': false, "UserToken": true },
        data: {
            project_id: 149
        }
    })
}

// 更新购物车信息
export function shopCarUpdate(id,data){
    return request({
        url:`/shoppingCart/${id}`,
        method:"PUT",
        data,
        headers:{'isToken':false , "UserToken":true}
    })
}

// 获取用户信息
export function getUserInfo(){
    return request({
        url:"user/userInfo",
        method:"GET",
        headers:{'isToken':false , "UserToken":true}
    })
}

// 退出登陆
export function loginOut(data){
    return request({
        url:'/logout',
        method:'POST',
        data,
        headers:{'isToken':false , "UserToken":true}
    })
}

// 修改用户信息
export function userModif(id,data){
    return request ({
        url:`user/${id}`,
        method:"PUT",
        data,
        headers:{'isToken':false , "UserToken":true}
    })
}

//获取用户填写的地址列表
export function getAddress(params){
    return request({
        url:`/address`,
        method:"GET",
        params,
        headers:{'isToken':false , "UserToken":true}
    })
}

// 添加地址
export function addAddress(data){
    return request({
        url:"/address",
        method:"POST",
        data,
        headers:{'isToken':false , "UserToken":true}
    })
}

// 删除地址
export function delAddress(id,data){
    return request({
        url:`/address/${id}`,
        method:"DELETE",
        data,
        headers:{'isToken':false , "UserToken":true}
    })
}

// 修改地址
export function updataAddress(id,data){
    return request({
        url:`/address/${id}`,
        method:"PUT",
        data,
        headers:{'isToken':false , "UserToken":true}
    })
}

// 修改默认地址
export function DefaultAddress(id,data){
    return request({
        url:`/setDefault/${id}`,
        method:"POST",
        data,
        headers:{'isToken':false , "UserToken":true}
    })
}

// 获取默认地址
export function getDefault(params){
    return request({
        url:'/defalutAddress',
        method:'GET',
        params,
        headers:{'isToken':false , "UserToken":true}
    })
}

// 提交订单
export function setOrder(data) {
    return request({
        url: "/order",
        method: "POST",
        data,
        headers:{'isToken':false , "UserToken":true}
    })
}

// 获取订单列表
export function getOrder(params) {
    return request({
        url: "/order",
        method: "GET",
        params,
        headers:{'isToken':false , "UserToken":true}
    })
}
export const orderpay = (data) => {
    return request({
      url: "/orderpay",
      method: "POST",
        data,
        headers:{'isToken':true , "UserToken":true}
    });
  };
//确认收货删除订单
export function delOrder(id, data) {
    return request({
        url: `order/${id}`,
        method: "DELETE",
        data,
        headers:{'isToken':false , "UserToken":true}
    })
}
//生成支付链接
export function wechatpay(data) {
    return request({
        url: "/wechatpay",
        method: "post",
        data,
        headers:{'isToken':true , "UserToken":true}
    })
}
export function Checkwechatpay(params) {
    return request({
        url: "/wechatpay",
        method: "GET",
        params,
        headers:{'isToken':true , "UserToken":true}
    })
}
export function getGoodsSku(params){
    return request({
        url:'/getSku',
        method:'GET',
        params,
        headers:{'isToken':false , "UserToken":true}
    })
}
export function getAllCity(params){
    return request({
        url:'/city',
        method:'GET',
        // params,
        headers:{'isToken':false , "UserToken":true}
    })
}

export function Test(params){
    return request({
        url:'/city',
        method:'GET',
        // params,
        headers:{'isToken':false , "UserToken":true}
    })
}
